package unit3.part2;

import java.util.Scanner;

/**
 * 水仙花数
 */
public class DaffodilsNum {

    public static void main(String[] args) {
        System.out.println("请输入0-1000内的数字：");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        scanner.close();
        if (num < 0 || num > 1000) { // 数值必须在1000以内
            System.out.println("输入的不是0-1000内的数字！");
            return;
        }
        // 获取个位数: n%10，获取十位数: n/10%10，获取百位数: n/100
        int ones = num % 10;
        int tens = num / 10 % 10;
        int hundreds = num / 100 % 10;
        if (num == (ones * ones * ones + tens * tens * tens + hundreds * hundreds * hundreds)) {
            System.out.println(num + "是水仙花数！");
        } else
            System.out.println(num + "不是水仙花数！");
    }
}